function showColum(){
    $("#column").show();
}

function showUser(){    
    Global.common.chooseType = "PTYH";
    var content = document.querySelector("#columnResult"),	
        contenthtml = "";
        content.innerHTML = contenthtml;
        contenthtml = "<li onclick=\"changeUserType('PTYH')\"><img class=\"titleimg\" src=\"resources/images/PTYH.png\">普通用户</li>"+
                      "<li onclick=\"changeUserType('ZZDH')\"><img class=\"titleimg\" src=\"resources/images/ZZDH.png\">种植大户</li>"+
                      "<li onclick=\"changeUserType('QYYH')\"><img class=\"titleimg\" src=\"resources/images/QYYH.png\">企业</li>"+		
                      "<li onclick=\"changeUserType('JDYH')\"><img class=\"titleimg\" src=\"resources/images/JDYH.png\">基地</li>"+
                      "</br>"+	
                      "<li onclick=\"changeUserType('HZSYH')\"><img class=\"titleimg\" src=\"resources/images/HZSYH.png\">合作社</li>"+	
                      "<li onclick=\"changeUserType('GXSYH')\"><img class=\"titleimg\" src=\"resources/images/GXSYH.png\">供销社</li>"+		                     		
                      "<li onclick=\"changeUserType('QT')\"><img class=\"titleimg\" src=\"resources/images/QT.png\">其他</li>"+	
                      "<li onclick=\"changeUserType('ZMXC')\"><img class=\"titleimg\" src=\"resources/images/PTYH.png\">最美乡村</li>"+	
                      "</br>";
        content.innerHTML = contenthtml;
        closeResultDiv();
        closeSearchResult();
        $("#columnResultDiv").slideDown(700);
}

function showeExpert(){   
    Global.common.chooseType = "EXPERT";
    var content = document.querySelector("#columnResult"),	
        contenthtml = "";
        content.innerHTML = contenthtml;
        contenthtml = "<li onclick=\"changeUserType('EXPERT')\"><img class=\"titleimg\" src=\"resources/images/EXPERT.png\">粮油专家</li>"+
                      "<li onclick=\"changeUserType('EXPERT')\"><img class=\"titleimg\" src=\"resources/images/EXPERT.png\">水果专家</li>"+
                      "<li onclick=\"changeUserType('EXPERT')\"><img class=\"titleimg\" src=\"resources/images/EXPERT.png\">蔬菜专家</li>"+		
                      "<li onclick=\"changeUserType('EXPERT')\"><img class=\"titleimg\" src=\"resources/images/EXPERT.png\">水产专家</li>";
        content.innerHTML = contenthtml;
        closeResultDiv();
        closeSearchResult();
        $("#columnResultDiv").slideDown(700);
}

function showAgri(){ 
    Global.common.chooseType = "nongqing";
    var content = document.querySelector("#columnResult"),	
        contenthtml = "";
        content.innerHTML = contenthtml;
        contenthtml = "<li onclick=\"loadAgri()\"><img class=\"titleimg\" src=\"resources/images/nongqing.png\">农情</li>"+
                      "<li onclick=\"loadDisa()\"><img class=\"titleimg\" src=\"resources/images/zaiqing.png\">灾情</li>";
        content.innerHTML = contenthtml;
    closeResultDiv();
    closeSearchResult();
    $("#columnResultDiv").slideDown(700);
}

function loadAgri(){
    localStorage.setItem("type", "nongqing");
    Global.common.chooseType = "nongqing";
    $("#chooseType").text(setMethod("nongqing"));
}

function loadDisa(){
    localStorage.setItem("type", "zaiqing");
    Global.common.chooseType = "zaiqing";
    $("#chooseType").text(setMethod("zaiqing"));
}

function closeResultDiv(){
    $("#columnResultDiv").hide();
}

function closeSearchResult(){
    $("#searchResult").hide();
}

function changeUserType(param){
	localStorage.setItem("param", param);
    Global.common.chooseType = param;
    $("#chooseType").text(setMethod(param));
    Global.common.param1 = "everyDay," + param;
    loadLayer(261);   
}

function findUser(){
    $("#serachInput").attr('placeholder','请输入搜索目标');    
    var searchContent = $("#serachInput").val();
    if( searchContent == "" ){
        // $("#serachInput").attr('placeholder','搜索信息不能为空');
        if( Global.common.chooseType == "nongqing" ){          
            loadLayer(58);
        } else if( Global.common.chooseType == "zaiqing" ){
            loadLayer(233);	
        } else {
            Global.common.param1 = "everyDay," + urlparam;
			loadLayer(261);
        }
    }else{
        var searchResult = document.querySelector("#searchResult"),
            searchResultHtml = "";
            searchResult.innerHTML = searchResultHtml;
        if( Global.common.chooseType == "nongqing" || Global.common.chooseType == "zaiqing" ){
            //url="search/searchAgriAndDisaster?showName=" + searchContent; 
            url="search/searchAgriAndDisaster?areaCode=50&showName=" + searchContent +"&type=" + Global.common.chooseType; 
        } else{
            //url="UserController/getUserInfoByUserNameLike?showName=" + searchContent;
            url="UserController/searchVip?areaCode=50&showName=" + searchContent + "&type=" + Global.common.chooseType;
        }   
        console.log(Global.common.newUrl + url);
        $.ajax({
		    url: Global.common.newUrl + url,
		    type: "get",
		    dataType: "json",		
		    success: function(result){			
			    if(result.isSuccess){
				    var data = result.data;
				    if( data.length > 0){                        
                        for(i=0; i<data.length; i++ ){
                            if( Global.common.chooseType == "nongqing" || Global.common.chooseType == "zaiqing" ){
                                  searchResultHtml += "<div class=\"searchResultLi\">"+
                                               "<ul class=\"searchResultLiul\" onclick=\"setContent("+ data[i].userId +")\">"+
                                               "<li class=\"searchResultLili\">用户名: "+ data[i].username +"</li>";
                                               if( data[i].cropname !== "" && data[i].cropname !== null ){
                                                searchResultHtml += "<li class=\"searchResultLili\">类型: "+ data[i].cropname +"</li>";
                                               } else{
                                                searchResultHtml += "<li class=\"searchResultLili\">类型: 暂无数据</li>";  
                                               }
                                               if( data[i].descript !== "" && data[i].descript !== null ){
                                                searchResultHtml += "<li class=\"searchResultLili\" title=\""+ data[i].descript +"\" style=\"overflow: hidden; text-overflow:ellipsis; white-space: nowrap;\">描述: "+ data[i].descript +"</li>" + 
                                                                    "</ul>";
                                               } else{
                                                searchResultHtml += "<li class=\"searchResultLili\">描述: 暂无数据</li>" + 
                                                                    "</ul>";
                                               }                                              
                                               if( data[i].imgUrl !== "" && data[i].imgUrl !== null ){
                                                    var url1 = JSON.parse(data[i].imgUrl);
                                                    searchResultHtml += "<img class=\"searchResultLiimg\" onclick=\"openImageWin('"+ Global.common.newUrl + url1[0] +"')\" src=\""+ Global.common.newUrl + url1[0] +"\"/></div>";
                                                                    "<div class=\"searchResulline\"></div>";
                                               } else{
                                                    searchResultHtml += "<img class=\"searchResultLiimg\" src=\"resources/images/noimage.png\"/></div>"+
                                                                     "<div class=\"searchResulline\"></div>";
                                               }                                                                                                                                                                                                        
                            } else{
                                searchResultHtml += "<div class=\"searchResultLi\" style=\"height: 100px\">"+        
                                               "<img class=\"round_icon\" onclick=\"openImageWin('resources/images/noimage.png')\" src=\"resources/images/noimage.png\"/>"+                                       
                                               "<ul class=\"searchResultLiul\" onclick=\"setContent("+ data[i].userId +")\">"+                                               
                                               "<div class=\"searchResultLili\" style=\"margin-left: 8px; width: 100%; height: 30px;\" title=\""+ data[i].name +"\">用户名: "+ data[i].name +"</div>";
                                               if( data[i].businessScope !== "" && data[i].businessScope !== null ){
                                                    searchResultHtml += "<li class=\"searchResultLili\" style=\"margin-left: 8px; width: 100%; height: 30px\">经营范围: "+ data[i].businessScope +"</li>";
                                               } else{
                                                    searchResultHtml += "<li class=\"searchResultLili\" style=\"margin-left: 8px; width: 100%; height: 30px;\">经营范围: 暂无数据</li>";  
                                               }                                             
                                searchResultHtml +="<li class=\"searchResultLili\" style=\"margin-left: 8px; width: 100%\; height: 30px;\">所属区域: "+ data[i].countyName +"</li>"+
                                               "</ul>"+                                              
                                               "</div>"+
                                               "<div class=\"searchResulline\"></div>";
                            }                              
                        }
                        searchResult.innerHTML = searchResultHtml;
                        closeSearchResult();
                        $("#searchResult").slideDown(700);                              
				    }else{
                        alert("查无数据");
				    }
			    }											   
		    },
		    error:function(){
			    alert("error");
		    }			
	});
    }        
   
}

function setMethod(param){
   if( param == "PTYH" ){
       return "普通用户";
   } else if( param == "ZZDH" ){
       return "种植大户"; 
   }  else if( param == "EXPERT" ){
      return "专家"; 
   } else if( param == "QYYH" ){
       return "企业"; 
   } else if( param == "JDYH" ){
       return "基地"; 
   } else if( param == "HZSYH" ){
       return "合作社"; 
   } else if( param == "GXSYH" ){
       return "供销社"; 
   } else if( param == "QT" ){
       return "其他"; 
   } else if( param == "ZMXC" ){
    return "最美乡村"; 
   } else if( param == "zaiqing" ){
    return "灾情调查"; 
   } else if( param == "nongqing" ){
    return "农情调查"; 
   }
}